<template>
	<div class="main">
		<van-address-list :switchable="false" :list="list" default-tag-text="默认" @add="onAdd" @edit="onEdit" />
	</div>
</template>

<script setup>
import { reactive, toRefs, onMounted, computed, getCurrentInstance, watch, defineEmits, ref } from 'vue';
import { useStore } from 'vuex';
import { AddressList } from '@s/address';
const { proxy } = getCurrentInstance();
const data = reactive({
	list: [],
});
const { list, disabledList } = toRefs(data);
const onAdd = () => {
	proxy.$router.push('/addressEdit');
};
const index = 0;
AddressList({ uid: proxy.$store.state.user.userInfo.id }).then((res) => {
	const resList=res.data.data
	data.list = resList.map(item => {
        return {
          id: item.id,
          name: item.uname,
          tel: item.aphone,
          address:item.address,
          isDefault: item.isdefault==1 ? true:false
        }
      })
});
const onEdit = (item, index) =>{
	proxy.$router.push({
		path:'/addressEdit',
		query:{
			id:item.id
		}
	})
}
const emit = defineEmits(['isNav', 'isBar','loading']);
onMounted(() => {
	// 初始化活动状态
	emit('isBar');
	emit('isNav');
		emit('loading');
});
</script>

<style lang="scss" scoped>
.main {
	padding-top: 40px;
}
</style>
